package com.yjzx.util.common.util.excel.alibaba;

import com.alibaba.excel.context.AnalysisContext;

import java.util.List;

/**
 * @author yjzx
 * @date 2024/8/18
 * @description
 */
public class SkipExcelListener<T> extends ExcelListener<T>{

    private int skipRows = 0;
    private final int skipRowStart;
    private final int skipRowEnd;

    public SkipExcelListener(List<List<String>> head, int skipRowStart, int skipRowEnd) {
        super(head);
        this.skipRowStart = Math.max(0, skipRowStart);
        this.skipRowEnd = Math.max(0, skipRowEnd);
    }

    @Override
    public void invoke(T t, AnalysisContext analysisContext) {
        if (this.skipRows >= skipRowStart && this.skipRows++ < skipRowEnd) {
            super.invoke(t, analysisContext);
        }
    }
}
